/* libgeisyr.c - Implementierung der Geisyr-Bibliotheken */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "libgeisyr.h"


/* Deklaration lokaler Funktionen */

//static int ReadRawSensorValue(void);


/* Implementierung */

int GetNodeSensorList(char* nodename, struct tsensorlist** sensorlist, int* arraylength)
{
	int sensoranzahl=0;
	sensoranzahl = 10;
	*sensorlist = (struct tsensorlist*) malloc(sizeof(struct tsensorlist) * sensoranzahl);
	strcpy ((*sensorlist)[0].sensorpath, "schlafzimmer:fenster1");
	(*sensorlist)[0].sensortype = 1;
	*arraylength = sensoranzahl;
	return 0;
}


int GetAllSensorList(struct tsensorlist** sensorlist, int* arraylength)
{
	int sensoranzahl=0;
	sensoranzahl = 200;
	*sensorlist = (struct tsensorlist*) malloc(sizeof(struct tsensorlist) * sensoranzahl);
	strcpy ((*sensorlist)[0].sensorpath, "schlafzimmer:fenster1");
	(*sensorlist)[0].sensortype = 1;
	*arraylength = sensoranzahl;
	return 0;
}


int GetTempSensorValue(char* sensorpath, int unit, double* temp) // unit: 0: °C, 1: °F, 2: K
{
	*temp = 10.5;
	return 0;
}


int GetWindowSensorState(char* sensorpath, int* windowopen) // windowopen: 0 = zu, ungleich 0 = auf
{
	*windowopen = 1;
	return 0;
}


int GetAllWindowSensorState(struct twindowstate** windowstatelist, int* arraylenth)
{
	int sensoranzahl=0;
	sensoranzahl = 30;
	*windowstatelist = (struct twindowstate*) malloc(sizeof(struct twindowstate) * sensoranzahl);
	strcpy ((*windowstatelist)[0].sensorpath, "schlafzimmer:fenster2");
	(*windowstatelist)[0].windowopen = 0;
	*arraylenth = sensoranzahl;
	return 0;
}


int GetBrightness(char* sensorpath, double* brightness)
{
	*brightness = 0.875;
	return 0;
}


int GetRoomStatus(char* roomname, struct troomstatus* roomstatus)
{
	strcpy (roomstatus->activity, "Physikpraktikum");
	return 0;
}


int GetAlternativeRooms(char* roomname, int roomquantity, troomname** altroomlist)
{
	if(roomquantity < 2) roomquantity=2;
	*altroomlist = (troomname*) malloc(sizeof(troomname) * roomquantity);
	strcpy ((*altroomlist)[0], "G.219");
	strcpy ((*altroomlist)[1], "G.205");
	return 0;
}


int SetRoomReservation(struct troomreservation* roomreservation)
{
	//
	return 0;
}


